package com.example.smartcity_poverty.ui.AllService.LivingPayment.activity

import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.MenuItem
import com.example.smartcity_poverty.R
import com.example.smartcity_poverty.logic.util.Util.show
import kotlinx.android.synthetic.main.activity_lp_add_true.*

/**
 * 缴费成功页面
 */
class LpAddTrueActivity : AppCompatActivity() {

    // 接收号码
    private val phoneNumber by lazy { intent.getStringExtra("phone") }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        supportActionBar?.setDisplayHomeAsUpEnabled(true)
        setContentView(R.layout.activity_lp_add_true)
        title = "缴费成功"

        val phoneNumberAdd = phoneNumber.toString()

        // 点击返回
        lpAddTrueOk.setOnClickListener { finish() }
        // 点击添加常用号码
        lpAddTrueAddPhone.setOnClickListener {
            getSharedPreferences("phone", Context.MODE_PRIVATE)
                .edit()
                .putString("phone", phoneNumberAdd)
                .apply()
            "添加成功！".show()
        }

    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        finish()
        return super.onOptionsItemSelected(item)
    }
}